package com.leruan.aasimp.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.leruan.aasimp.dao.CarPartsDao;
import com.leruan.aasimp.entity.CarParts;

public class CarPartsDaoImpl extends HibernateDaoSupport implements CarPartsDao{

	public void addPart(CarParts carParts) {
		Session session = this.getSession();
		session.save(carParts);
		
	}

	@SuppressWarnings("unchecked")
	public List<CarParts> getAllParts() {
		Session session = this.getSession();
		Criteria cri = session.createCriteria(CarParts.class);
		Criterion  c = Expression.eq("status", "1");
		cri.add(c);
		List<CarParts> list = cri.list();
		return list;
	}

}
